import { createRouter, createWebHistory } from 'vue-router'
// import HomeView from '../views/HomeView.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      // name: 'home',
      component: () => import("@/views/Layout/index.vue"),
      children: [
        {
          path: '',
          component: () => import("@/views/Home/index.vue"),
        },
        {
          path: "/category/:id",
          // component: () => import("@/views/category/index.vue"),
          component: () => import("@/views/Category/index.vue"),
        },
        {
          path: "/category/sub/:id",
          component: () => import("@/views/SubCategory/index.vue"),
        },
        {
          path: "/detail/:id",
          component: () => import("@/views/Detail/index.vue"),
        },
        {
          path: "/cartlist",
          component: () => import("@/views/Cart/index.vue"),
        },
        {
          path: "/checkout",
          component: () => import("@/views/Checkout/index.vue"),
        },
        {
          path: "/pay",
          component: () => import("@/views/Pay/index.vue"),
        },
        {
          path: "/paycallback",
          component: import("@/views/Pay/PayBack.vue"),
        },
        {
          path: "/member",
          component: import("@/views/Member/index.vue"),
          children: [
            {
              path: "",
              component: import("@/views/Member/component/UserInfo.vue"),
            },
            {
              path: "order",
              component: import("@/views/Member/component/UserOrder.vue"),
            },
          ],
        },
      ],
    },
    {
      path: '/login',
      // name: 'about',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('@/views/Login/index.vue'),
    },

  ],
  //路由行为定制
  scrollBehavior() {
    return {
      top: 0
    }
  }
});

// const router = createRouter({
//   history: createWebHistory(import.meta.env.BASE_URL),
//   routes: [
//     {
//       path: '/',
//       // name: 'home',
//       // component: () => import("@/views/Layout/index.vue"),
//       redirect: "/home",
//       children: [],
//     },
//     {
//       path: '/home',
//       component: () => import("@/views/Home/index.vue"),
//     },
//     {
//       path: "/category/:id",
//       // component: () => import("@/views/category/index.vue"),
//       component: () => import("@/views/Category/index.vue"),
//     },
//     {
//       path: "/category/sub/:id",
//       component: () => import("@/views/SubCategory/index.vue"),
//     },
//     {
//       path: '/login',
//       // name: 'about',
//       // route level code-splitting
//       // this generates a separate chunk (About.[hash].js) for this route
//       // which is lazy-loaded when the route is visited.
//       component: () => import('@/views/Login/index.vue'),
//     },
//     {
//       path: "/detail/:id",
//       component: () => import("@/views/Detail/index.vue"),
//     },
//   ],
//   //路由行为定制
//   scrollBehavior() {
//     return {
//       top: 0
//     }
//   }
// });

export default router;
